#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int const len = 7;
int const opt[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};

struct cmp
{
	bool operator()(int a, int b)
	{
		int ta = a, tb = b;
		int s1 = 0, s2 = 0;
		long long t1 = 1, t2 = 1;
		for (int i = 0; i < len; i++, a /= 10, b /= 10) {
			s1 += a % 10;  s2 += b % 10;
			t1 *= (a % 10 + 1); t2 *= (b % 10 + 1);
		}
		return (s1 < s2 || (s1 == s2 && t1 < t2) || (s1 == s2 && t1 == t2 && ta < tb));
	}
} cmp;

void print(int x)
{
	std::string out = std::to_string(x);
	out = std::string(len - (int)out.size(), '0') + out;
	std::cout << out << '\n';
}

int sum(int x)
{
	int ret = 0;
	for (int i = 0; i < len; i++, x /= 10) ret += x % 10;
	return ret;
}

int main()
{
	std::ios::sync_with_stdio(false);
	std::vector<int> v;
	for (int i = 0; i < opt[len]; i++) v.push_back(i);
	std::sort(v.begin(), v.end(), cmp);
	int t = 0, prev = sum(v[0]);
	for (auto i : v)
		if (sum(i) != prev) {
			std::cout << prev << "  " << t << '\n';
			t = 0;
			prev = sum(i);
		} else t++;
	std::cout << '\n';
}

